// pages/user/user.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    userInfo:{},
    order: '/pages/order/order',
    collect: '/pages/collect/collect',
    collectNums: 0
  },
  onShow() {
    const userInfo = wx.getStorageSync('userInfo');
    this.setData({
      userInfo
    });
    this.getCollectNum();
  },
  //提示函数
  onPrompt() {
    if (this.data.userInfo !== '') return;
    wx.showToast({
      title: '您还没有登陆哦~',
      icon: 'none'
    }) 
  },
  //加载收藏商品数量
  getCollectNum() {
    //如果没有登陆则不拉取数据
    if (this.data.userInfo === '') return;
    const collect = wx.getStorageSync('collect') || [];
    this.setData({
      collectNums: collect.length
    });
  },
  //分享
  onShareAppMessage: function () { 
    return {
      title: "等鱼星购",
      path:`/pages/index/index`,
      imageUrl: 'https://img2.woyaogexing.com/2021/02/24/e32bab51bb42464a977ca3ea2a3c01f2!400x400.jpeg'
    }
 
  }

})